const Category = require("../model/category");

/**
 * 分类标签中间件
 */
module.exports = {
  /**
   * 获取分类标签
   */
  getList:(req,res,next)=>{
    Category.getList()
    .then((res) => {
      req.category = res;
      next();
    })
    .catch((err) => {
      next(err);
    });
  },
  // 获取指定分类标签
  getCategoryId:(req,res,next)=>{
    // 获取地址栏传递的id值
    let id = req.query.id
    Category.getCategoryId(id)
    .then((res) => {
      req.categoryInfo = res;
      next();
    })
    .catch((err) => {
      next(err);
    });
  }
};
